<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>函数计算器</title>
  <script>
    var tan = prompt('1.加法运算\n2.减法运算\n3.乘法运算\n4.除法运算\n5.退出')

    function jisuan (shuzi) {
      var num1 = parseInt(prompt('请输入第一个数字：'))
      var num2 = parseInt(prompt('请输入第二个数字：'))
      var result
      switch (parseInt(shuzi)) {
        case 1:
          result = num1 + num2
          break
        case 2:
          result = num1 - num2
          break
        case 3:
          result = num1 * num2
          break
        case 4:
          result = num1 / num2
          break
        case 5:
          break
      }
      alert(result)
      tan = prompt('1.加法运算\n2.减法运算\n3.乘法运算\n4.除法运算\n5.退出')
    }

    while (true) {
      if (tan == '1') {
        jisuan('1')   //调用函数jisuan()  并把'1'赋值给 shuzi
      }
      if (tan == '2') {
        jisuan('2')
      }
      if (tan == '3') {
        jisuan('3')
      }
      if (tan == '4') {
        jisuan('4')
      }
      if (tan == '5') {
        break
      }
    }
  </script>
</head>
<body>

</body>
</html>